﻿using System;

namespace personalplaner.business.extensions
{
	public static class DateTimeExtensions
	{
		public static string ShortDayOfWeek(this DateTime date)
		{
			switch (date.DayOfWeek)
			{
				case DayOfWeek.Monday:
					return "MO";

				case DayOfWeek.Tuesday:
					return "DI";

				case DayOfWeek.Wednesday:
					return "MI";

				case DayOfWeek.Thursday:
					return "DO";

				case DayOfWeek.Friday:
					return "FR";

				case DayOfWeek.Saturday:
					return "SA";

				case DayOfWeek.Sunday:
					return "So";

			}

			return "";
		}

		public static int ToInt(this DateTime value)
		{
			var date = value.ToShortDateString();
			return int.Parse(String.Format("{0}{1}{2}{3}{4}{5}{6}{7}", date[6], date[7], date[8], date[9], date[3], date[4], date[0], date[1]));
		}
	}
}
